<include file="public@header"/>
<style>
    th,td{
        text-align: center;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Mei/weiList')}">维修开锁列表</a></li>
        <li><a href="{:url('Mei/weiAdd')}">添加维修开锁</a></li>
        <li><a href="{:url('Mei/weiCate')}">添加维修开锁类别</a></li>
    </ul>
    <form id="submitForm" class="well form-inline margin-top-20" method="post" action="{:url('Mei/weiList')}">&nbsp;
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$keyword|default=''}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger"  href="{:url('Mei/weiList')}" >清空</a>
    </form>
    <a href="{:url('portal/mei/login')}" target="_blank">开锁公司后台登录地址</a>
    <form class="js-ajax-form" action="" method="post">
        <button style="margin: 5px;" class="btn btn-danger btn-sm js-ajax-submit" type="submit"
                data-action="{:url('wuye/dels')}" data-subcheck="true" data-msg="您确定删除吗？">
            {:lang('DELETE')}
        </button>
        <input type="hidden" name="table" value="mei_business">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="200">名称</th>
                <th width="200">账号</th>
                <th width="200">分类</th>
                <th width="200">电话</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <notempty name="data">
                <foreach name="data" item="vo">
                    <tr>
                        <td>
                            <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                                   value="{$vo.id}" title="ID:{$vo.id}">
                        </td>
                        <td>{$vo.name}</td>
                        <td><a href="javascript:;" onclick="pas({$vo.id})">{$vo.account}</a></td>
                        <td>{$vo.infoName}</td>
                        <td>{$vo.phone}</td>
                        <td>
                            <a href="{:url('admin/mei/weiAdd',['id'=>$vo.id])}">编辑</a>
                            <a href="javascript:;" onclick="del({$vo.id},'mei_business');">删除</a>
                        </td>
                    </tr>
                    <script>
                        layer.photos({
                            photos: '#layer-photos-demo{$vo.id}'
                            ,anim: <?php echo rand(1,6)?>
                        });
                    </script>
                </foreach>
            </notempty>
            <tfoot>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th width="200">名称</th>
                <th width="200">账号</th>
                <th width="200">分类</th>
                <th width="200">电话</th>
                <th width="100">操作</th>
            </tr>
            </tfoot>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__TMPL__/public/assets/js/layer.js"></script>
<script src="__TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
<script>
    function del(id,table) {
        layer.confirm('是否删除？删除之后无法恢复', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:url('Mei/del')}",
                data:{'id':id,'table':table},
                type:"Post",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg,{icon: 6,time: 1000},function () {
                        location.reload();
                    });
                }
            });
        }, function(){

        });
    }
    function pas(id) {
        $.ajax({
            type: "POST",
            url: "{:url('Mei/businessPas')}",
            data: {id:id},
            dataType:"json",
            success: function(res){
                layer.prompt({title: res.msg, formType: 0,value:res.data}, function(text, index){
                    console.log(text);
                    $.ajax({
                        type: "POST",
                        url: "{:url('Mei/businessPas')}",
                        data: {id:id,psd:text},
                        dataType:"json",
                        success: function(res){
                            layer.msg(res.msg,{icon: 6});
                            layer.close(index);
                        }
                    });
                });
            }
        });
    }
</script>
</body>
</html>